package com.lg.fileservice.model;

import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

public class StorageBo {

    private String objectName;

    /*上传的文件*/
    private MultipartFile multipartFile;

    /*上传文件的byte*/
    private byte[] content;

    /*上传文件流*/
    private InputStream inputStream;

    /*批量处理文件*/
    private List<StorageBo> objectList;

    /**
     * 文件后缀，如jpg
     */
    private String ext;

    private String author;

    private String groupName;

    private String remoteFileName;

    private Object client;

    private String bucketName;

    private String endpoint;

    private String pre;

    /**
     * 账号
     */
    private String accessKeyId;

    /**
     * 账号的密码
     */
    private String accessKeySecret;

    private StorageBo(Builder builder) {
        this.author = builder.author;
        this.ext = builder.ext;
        this.objectList = builder.objectList;
        this.inputStream = builder.inputStream;
        this.objectName = builder.objectName;
        this.multipartFile = builder.multipartFile;
        this.content = builder.content;
        this.groupName = builder.groupName;
        this.remoteFileName = builder.remoteFileName;
        this.client = builder.client;
        this.bucketName = builder.bucketName;
        this.pre = builder.pre;
        this.endpoint = builder.endpoint;
        this.accessKeyId = builder.accessKeyId;
        this.accessKeySecret = builder.accessKeySecret;
    }

    public static class Builder {

        //客户端
        private Object client;

        /*文件名字*/
        private String objectName;

        /*上传的文件*/
        private MultipartFile multipartFile;

        /*上传文件的byte*/
        private byte[] content;

        /*上传文件流*/
        private InputStream inputStream;

        /*批量处理文件*/
        private List<StorageBo> objectList;

        private String groupName;

        private String remoteFileName;
        /**
         * 文件后缀，如jpg
         */
        private String ext;

        private String author;

        private String bucketName;

        private String pre;

        private String endpoint;

        private String accessKeyId;

        private String accessKeySecret;

        public Builder setAccessKeyId(String accessKeyId) {
            this.accessKeyId = accessKeyId;
            return this;
        }

        public Builder setAccessKeySecret(String accessKeySecret) {
            this.accessKeySecret = accessKeySecret;
            return this;
        }
        public Builder setEndpoint(String endpoint) {
            this.endpoint = endpoint;
            return this;
        }

        public Builder setPre(String pre) {
            this.pre = pre;
            return this;
        }

        public Builder setBucketName(String bucketName) {
            this.bucketName = bucketName;
            return this;
        }

        public Object getClient() {
            return client;
        }

        public Builder setClient(Object client) {
            this.client = client;
            return this;
        }

        public Builder setObjectName(String objectName) {
            this.objectName = objectName;
            return this;
        }

        public Builder setMultipartFile(MultipartFile multipartFile) {
            this.multipartFile = multipartFile;
            return this;
        }

        public Builder setContent(byte[] content) {
            this.content = content;
            return this;
        }

        public Builder setInputStream(InputStream inputStream) {
            this.inputStream = inputStream;
            return this;
        }

        public Builder setObjectList(List<StorageBo> objectList) {
            this.objectList = objectList;
            return this;
        }

        public Builder setGroupName(String groupName) {
            this.groupName = groupName;
            return this;
        }

        public Builder setRemoteFileName(String remoteFileName) {
            this.remoteFileName = remoteFileName;
            return this;
        }

        public Builder setExt(String ext) {
            this.ext = ext;
            return this;
        }

        public Builder setAuthor(String author) {
            this.author = author;
            return this;
        }

        public StorageBo build() {
            return new StorageBo(this);
        }
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }
    public String getAccessKeySecret() {
        return accessKeySecret;
    }
    public String getEndpoint() {
        return endpoint;
    }
    public String getPre() {
        return pre;
    }
    public Object getClient() {
        return client;
    }

    public String getBucketName(){
        return bucketName;
    }


    public String getObjectName() {
        return objectName;
    }


    public MultipartFile getMultipartFile() {
        return multipartFile;
    }


    public byte[] getContent() {
        return content;
    }


    public InputStream getInputStream() {
        return inputStream;
    }


    public List<StorageBo> getObjectList() {
        return objectList;
    }


    public String getExt() {
        return ext;
    }


    public String getAuthor() {
        return author;
    }

    public String getGroupName() {
        return groupName;
    }

    public String getRemoteFileName() {
        return remoteFileName;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"objectName\":\"")
                .append(objectName).append('\"');
        sb.append(",\"multipartFile\":")
                .append(multipartFile);
        sb.append(",\"content\":")
                .append(Arrays.toString(content));
        sb.append(",\"inputStream\":")
                .append(inputStream);
        sb.append(",\"objectList\":")
                .append(objectList);
        sb.append(",\"ext\":\"")
                .append(ext).append('\"');
        sb.append(",\"author\":\"")
                .append(author).append('\"');
        sb.append(",\"groupName\":\"")
                .append(groupName).append('\"');
        sb.append(",\"remoteFileName\":\"")
                .append(remoteFileName).append('\"');
        sb.append(",\"client\":")
                .append(client);
        sb.append('}');
        return sb.toString();
    }
}
